﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using Mbs.ComponentModel;

namespace Mbs.Modularity
{
    /// <summary>
    /// 模块信息类
    /// </summary>
    [Serializable]
    [DebuggerDisplay("First={First},Id={Id},State={State},Description={Description}")]
    public class ModuleInfo : IKey<int>
    {
        

        public ModuleInfo(int id, int  moduleId, ModuleState state, IModuleMeta meta)
        {
            Id = id;
            ModuleId = moduleId;
            State = state;
            Meta = meta;
        }

        /// <summary>
        /// 标识Id
        /// </summary>
        [LocalizedProperty(Name = "Global.Id")]
        public int Id { get; private set; }

        /// <summary>
        /// 模块Id
        /// </summary>
        public int ModuleId { get; private set; }

        /// <summary>
        /// 模块元数据
        /// </summary>
        public readonly IModuleMeta Meta;

        /// <summary>
        /// 模块名称
        /// </summary>
        [LocalizedProperty(Name = "Global.Name")]
        public string Name
        {
            get { return Meta.AddIn.Name; }
        }

        /// <summary>
        /// 模块状态
        /// </summary>
        [LocalizedProperty(Name = "Global.State")]
        [TypeConverter(typeof(EnumTypeConverter))]
        public ModuleState State{get;private set;}

        /// <summary>
        /// 启动方式
        /// </summary>
        [LocalizedProperty(Name = "Global.StartMode")]
        [TypeConverter(typeof(EnumTypeConverter))]
        public StartMode StartMode { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [LocalizedProperty(Name = "Global.Description")]
        public string Description
        {
            get { return Meta.AddIn.Description; }
        }
    }
}